<template>
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-sys__user">
      <el-form
        :inline="true"
        :model="dataForm"
        @keyup.enter.native="getDataList()"
      >
        <el-form-item>
          <el-input
            v-model="dataForm.name"
            placeholder="标题"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <ren-select
            v-model="dataForm.source"
            dict-type="warn_info"
            placeholder="来源"
          ></ren-select>
        </el-form-item>
        <el-form-item>
          <el-select v-model="dataForm.status">
            <el-option label="全部" :value="''"></el-option>
            <el-option label="正常" :value="0"></el-option>
            <el-option label="停用" :value="1"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">{{ $t("query") }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button @click="result()">重置</el-button>
        </el-form-item>
      </el-form>
      <div class="table-top">
        <div class="left">
          <div class="top-line"></div>
          预警信息列表
        </div>
        <div class="right">
          <div class="table-top-btn" @click="addOrUpdateHandle()">新增</div>
          <div class="table-top-btn" @click="deleteHandle()">删除</div>
        </div>
      </div>
      <el-table
        v-loading="dataListLoading"
        :data="dataList"
        border
        stripe
        @selection-change="dataListSelectionChangeHandle"
        @sort-change="dataListSortChangeHandle"
        style="width: 100%"
      >
        <el-table-column
          type="selection"
          header-align="center"
          align="center"
          width="50"
        ></el-table-column>
        <el-table-column
          prop="title"
          label="标题"
          header-align="center"
          show-overflow-tooltip
          align="center"
        ></el-table-column>
        <el-table-column
          prop="source"
          label="来源"
          header-align="center"
          show-overflow-tooltip
          align="center"
        ></el-table-column>
        <el-table-column
          prop="publishDate"
          label="发布日期"
          sortable
          header-align="center"
          show-overflow-tooltip
          align="center"
        ></el-table-column>
        <el-table-column
          prop="createTime"
          label="创建日期"
          sortable
          header-align="center"
          show-overflow-tooltip
          align="center"
        ></el-table-column>
        <el-table-column
          prop="status"
          label="状态"
          header-align="center"
          show-overflow-tooltip
          align="center"
        >
          <template slot-scope="scope">
            <el-tag v-if="scope.row.status === 0" size="small" type="success">正常</el-tag>
            <el-tag v-else size="small" type="danger">停用</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          prop="creatorName"
          label="创建者"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          :label="$t('handle')"
          fixed="right"
          header-align="center"
          align="center"
          width="100"
        >
          <template slot-scope="scope">
            <el-button
              type="text"
              size="small"
              @click="addOrUpdateHandle(scope.row.id)"
              >{{ $t("update") }}</el-button
            >
            <el-button
              type="text"
              size="small"
              @click="deleteHandle(scope.row.id)"
              >{{ $t("delete") }}</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="+limit"
        :total="+total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle"
      >
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update
        v-if="addOrUpdateVisible"
        ref="addOrUpdate"
        @refreshDataList="query"
      ></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './warn-add-or-update'

export default {
  mixins: [mixinViewModule],
  data () {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/cgjybzHotInfo/page',
        getDataListIsPage: true,
        deleteURL: '/cgjybzHotInfo',
        deleteIsBatch: true,
        exportURL: ''
      },
      dataForm: {
        category: '预警信息',
        name: '',
        source: '',
        status: '',
      }
    }
  },
  components: {
    AddOrUpdate
  },
  created () {
  },
  methods: {
    result () {
      this.dataForm.name = ''
      this.dataForm.source = ''
      this.dataForm.status = ''
      this.getDataList()
    }
  }
}
</script>
